<?php

class hdms_pageController extends FoundryControllerInterface
{


	/**
	 * init()
	 *
	 * init() is called in place of the __construct() method used by the
	 * FoundryControllerInterface super class
	 * This function will be called immediately after the __construct method
	 *
	 */ 
	public function init()
	{
	
	
	}
	
	public function main()
	{
		$id = FoundryRequest::get( 'id', 'num' );
		
		if( $id ) {
			$page = $this->page( $id );
			
			if( $page->uid ) {
				return array( 'page' => $page );
			}
		} else {
			$id = FoundryRequest::get( 'id', 'alnum' );
						
			$id = str_replace( '_', ' ', urldecode( $id ) );
			
			if( $id ) {
				$mPage = $this->page();
				
				$page = $mPage->find( '*title = :t', array( ':t' => $id ) );
				
				if( $page[0]->uid ) {
					return array( 'page' => $page[0] );
				}
			}
			
		}
		return array( 'page' => $this->page() );
	}

}

?>